# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=backdoor-factory
pkgver=210.0c53045
pkgrel=3
epoch=1
groups=('blackarch' 'blackarch-backdoor' 'blackarch-binary')
pkgdesc='Patch win32/64 binaries with shellcode.'
url='https://github.com/secretsquirrel/the-backdoor-factory'
arch=('any')
license=('BSD')
depends=('python2' 'python2-capstone' 'python2-pefile' 'python2-setuptools')
makedepends=('git')
options=('!strip')
source=("$pkgname::git+https://github.com/secretsquirrel/the-backdoor-factory.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm COPYING LICENSE.txt README.md

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python2 /usr/share/$pkgname/backdoor.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

